<!--{template admin/header}-->
<body id="homepage">
    <div id="breadcrumb">
        <ul>
            <li><img src="static/img/icons/icon_breadcrumb.png"
                     alt="Location" /></li>
            <li><strong>位置:</strong></li>
            <li><a href="admin.php">主页</a> - 商店管理</li>
        </ul>
    </div>
    <div id="rightside" >
        <div class="contentcontainer">
            <div class="headings altheading">
            <h3><span class="nav_left">{$goods_name}商店</span></h3>
			  </div>
                <div class="paper-head">
					<div>
						<span class="nav_right"><a href="#add{$goods}" role="button" class="btn btn-primary btn-middle" data-toggle="modal">添加</a></span>			
						<div id="add{$goods}" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel_add{$goods}" aria-hidden="true" style="width:443px">
						<form id="shop{$goods}" action="planner.php">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
								<h3 id="myModalLabel_add{$goods}">添加{$goods_name}包</h3>
							</div>
							<div class="modal-body nav-category" style="max-height:800px;">
								<div class="input-prepend">
									<span class="add-on">id号</span>
									<input class="span4"  type="text" placeholder="id" name="id">
								</div>
								<div class="input-prepend">
									<span class="add-on">名称</span>
									<input class="span4"  type="text" placeholder="name" name="name">
								</div>
								<div class="input-prepend">
									<span class="add-on">介绍</span>
									<input class="span4"  type="text" placeholder="介绍" name="desc">
								</div>	
								<div class="input-prepend">
									<span class="add-on">推荐</span>
									<select name="label" class="span2">									
										<option value="0">否</option>	
										<option value="1">是</option>							
									</select>
								</div>
								<br/>
								<div class="input-prepend">
								<span class="add-on">标签</span>
								<select name="tag" class="span2" >
									<option value="new">最新</option>					
									<option value="hot">最热</option>
									<option value="">无</option>
								</select>
								</div>
								<br/>
								<div class="input-prepend">
									<span class="add-on">类型</span>
									<select name="category" class="span2" >
										<option value="">无</option>
										<!--{loop $categories $key=>$val}-->
											<option value="{$key}">{$val}</option>
										<!--{/loop}-->
									</select>
							   </div>							
						   </div>
						   <div class="modal-footer">
						   		<input type="hidden" name="ac" value="class"/>
						   		<input type="hidden" name="op" value="addPlanner{$goods}"/>
							    <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
							    <button type="button" id="submit" class="btn btn-primary layerLoad">添加</button>
						   </div>
						  </form>
						</div>
						<a class="btn btn-primary" id="refresh_planner" data-type="{$goods}" href="javascript:void(0);">
							刷新更新时间
						</a>
					</div>
				</div>
          
        <div class="contentbox">
                <table width="100%" class="table table-striped">
                    <thead>
                        <tr>
                        	<th style="width:5%">
                                 <div class="btn-group">
								  <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
								    批量操作 <span class="caret"></span>
								  </button>
								   <ul class="dropdown-menu">
									    <li><a href="#" class='batchAction layerLoad'  data-type='online'>资源上线</a></li>
									    <li><a href="#" class='batchAction layerLoad' data-type='offline'>资源下线</a></li>
									    <li><a href="#" class='batchAction layerLoad' data-type='common'>普通类型</a></li>									  
									    <li><a href="#" class='batchAction layerLoad' data-type='new'>new标签</a></li>
									    <li><a href="#" class='batchAction layerLoad' data-type='hot'>hot标签</a></li>
									    <li><a href="#" class='batchAction layerLoad' data-type='notag'>去除标签</a></li>
									    <li><a href="#" class='batchAction layerLoad' data-type='addlabel'>上推荐</a></li>
									    <li><a href="#" class='batchAction layerLoad' data-type='removelabel'>下推荐</a></li>
									</ul>
								</div>
                             </th>
                            <th>ID</th>
                            <th>封面</th>
                            <th>名称</th>
                            <th>任务</th>
                            <th>价格</th>
                            <th>状态</th>
                            <th>下载量</th>
							<th>上线时间</th>
							<!--{if $goods == 'Templets' || $goods == 'Bootmgrs'}-->
							<th>种类</th>
							<!--{/if}-->
							<th>类别</th>
                            <th>推荐</th>
                            <th>标签</th>
							<th>隐藏</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    
                    <tbody>
                  
                    	<!--{loop $list $value}-->
					<tr>
						<td>
						 <label class="cr-styled">
	                	 <input type="checkbox" class="batch" data-id="{$value[id]}">
	                 	 <i class="fa"></i>                
	                  	 </label>						
						</td>
					    <td><!--{$value[id]}--></td>
						<td><img height="40px" width="40px" src="{$value[cover_s]}"/></td>
						<td><!--{$value[name]}--></td>
						<td>
							<!--{if $value[task][type]}-->
							<span class="label label-important">
							<!--{$taskTypeArr[$value[task][type]]}-->限制,
							<!--{$value[task][desc]}-->
							</span>
							<!--{else}-->
							<span class="label">无任务限制</span>
							<!--{/if}-->
						</td>
						<td>
							<!--{if $value[price_final] > 0}-->
								<span class="badge badge-important">{$value[price_final]}</span> 金币
							<!--{else}-->
								免费
							<!--{/if}-->
						</td>
						<td>
							<!--{if $value[status] == 0}-->
								<i class="icon-ok"></i>
							<!--{else}-->
								<i class="icon-remove-circle"></i>
							<!--{/if}-->
						</td>
						<td><!--{$value['sale_amount']}--></td>	
						<td><!--{date('Y/m/d H:i:s',$value['time'])}--></td>
						<!--{if $goods == 'Templets' || $goods == 'Bootmgrs'}-->
						<td>
							<!--{if $value[kind] == 1}-->
								记录(1)
							<!--{elseif $value[kind] == 2}-->
								图片(2)
							<!--{else}-->
								未设置($value[kind])
							<!--{/if}-->
						</td>
						<!--{/if}-->
						<td>
							<!--{$value[category]}-->
						</td>
						<td>
						    <!--{if $value[label] == 1}-->
								<i class="icon-ok"></i>
							<!--{else}-->
								<i class="icon-remove-circle"></i>
							<!--{/if}-->
						</td>
						<td>
						<!--{if !empty($value[tag])}-->
							<!--{$value[tag][0][bg]}-->
						<!--{else}-->
							无
						<!--{/if}-->
						</td>
						<td>
							<!--{if $value[hidden] == 1}-->
							<i class="icon-ok"></i>
							<!--{else}-->
							<i class="icon-remove-circle"></i>
							<!--{/if}-->
						</td>
						<td>
						<a href="planner.php?ac=class&op=getPlanner{$goods}Detail&id={$value[id]}" target="_blank" role="button" class="btn btn-success btn-middle" >编辑</a>
						<!--{if $goods != 'Templets' && $goods != 'Bootmgrs'}-->
						<span class="nav_right"><a href="#addPlanner{$value[id]}" role="button" class="btn btn-primary btn-middle" data-toggle="modal">打包</a>
						<!--{if empty($value[download_url])}-->
								未打包
						<!--{else}-->
								已打包
						<!--{/if}-->
						</span>
						<!--{/if}-->
						</td>
															
						<div id="addPlanner{$value[id]}" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel_addPlanner{$goods}" aria-hidden="true">
						<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
								<h3 id="myModalLabel_add{$goods}">添加{$goods_name}包</h3>
						</div>
						
						<form  class="form-inline" role="form" method="post" action='admin.php?ac=pack&op=submit' enctype="multipart/form-data">									
						<div class="modal-body nav-category" style="max-height:800px;">
						       <div class="form-group">
							      <label>ID
							      <input type="text" class="form-control" name="id" placeholder="id" value={$value[id]} >
							      </label>
							   </div>
							   <div class="form-group">
							      <label>拼音名称
							      <input type="text" class="form-control" name="name" placeholder="请输入名称拼音">
							      </label>
							   </div>
							   <div class="form-group">
							      <label for="inputfile">选择包文件
							      <input type="file" id="inputfile" name="package">		
							      </label>			     
							   </div>
						  </div>
						   <div class="modal-footer">	
						   <input type="hidden" name="type" value="{$packtype}">
						   <input type="hidden" name="subtype" value="{$value['categoryNum']}">
						   <button type="submit" class="btn btn-default layerLoad" >提交</button>
						   </div>
						</form>
						</div>

					</tr>
					<!--{/loop}-->
				
                    </tbody>
                
                </table>
               
                
                <div style="clear: both;"></div>
            </div>
        <div class="extrabottom">
             <div class="bulkactions" style="float:right;">
                <ul class="pagination">
                    <li class="text">当前为第{$currtenPage}页</li>
                    <!--{if $prevpurl!=''}-->
                    <li class="text"><a href="{$firstpurl}" title="">第一页</a></li>
                    <li class="text"><a href="{$prevpurl}" title="">上一页</a></li>
                    <!--{/if}-->
                    <li class="text"><a href="{$nextpurl}" title="">下一页</a></li>
               </ul>
             </div>
        </div>
        </div>
    </div>
    <!--{template admin/leftside}-->
    <!--{template admin/footer}-->
   
    <script type="text/javascript">
			$(document).on('click','#refresh_planner',function () {
				var type = $(this).data('type');
				$.ajax({
					type:'GET',
					url:'planner.php?ac=class&op=updatePlanner',
					data:{type:type},
					success:function (data) {
						if(data==1){
							layer.msg(type+'更新成功!');
						}else{
							layer.msg(type+'更新失败');
						}
					}
				});
			})
    		$(document).on('click','#submit',function(){
    				var state ={0:'增加失败',1:'增加成功'};    			
    				$.ajax({
    						type:'GET',
    						url:'planner.php',
    						data:$('#shop{$goods}').serialize(),
	   						success:function(data){
	   							layer.alert(state[data]);
								setTimeout(function(){
									window.location.href="planner.php?ac=class&op=getPlanner{$goods}List";
								},1000);

	   						}
    				});   			
    		});
			 //批量操作
           	ids=[];
           	$('.batch').click(function(){
           		var id = $(this).data('id');
           		var index = $.inArray(id,ids);
      			if(index !== -1){
      				ids.splice(index,1);
      				$(this).attr('checked',false);
      			}else{
      				ids.push(id);
      				$(this).attr('checked',true);
      			}
      			
           	});
			$('.batchAction').click(function(){
             	
         		var actionType= $(this).data('type');
         		
         		if(typeof(actionType) == undefined){
         			layer.msg('类型选择有误！');
         			return false;
         		}
         		
         		if(ids.length==0){
         			layer.msg('请先勾选资源！');
         			return false;
         		}
         		$.ajax({
					type:'GET',
					url:'planner.php',
					data:{'ids' : ids,'actionType':actionType,'editType':'editPlanner{$goods}','op':'setBatchData'},
						success:function(data){
							if(data==1){
								layer.msg('操作成功!');
							}else{
								layer.msg('操作失败!')
							}
						    window.location.href="planner.php?ac=class&op=getPlanner{$goods}List";
													
						}
				});         	
         	}); 
	</script>